using IM.Easy.Infrastructure.Query;
using Microsoft.AspNetCore.Mvc;
using IM.Easy.MsgServices.Dtos;
using IM.Easy.MsgServices.IServices;
using IM.Easy.Entity.Msg;
using IM.Easy.Api.AccountManage;
using IM.Easy.Core.Attributes;
using IM.Easy.Core.AppContext;
using IM.Easy.SystemServices.IServices;
using IM.Easy.SystemServices.Services;

namespace IM.Easy.Api.Controllers.Msg
{
    /// <summary>
    /// EmailAccountController 控制器
    /// </summary>
    [Route("msg/emails/account")]
    public class EmailAccountController : ControllerBase
    {
        private readonly IEmailAccountService _service;
        private readonly IUserService _userService;

        /// <summary>
        /// 构造函数，   
        /// </summary>
        /// <param name="service">服务接口</param>
        public EmailAccountController(IEmailAccountService service, IUserService userService)
        {
            _service = service;
            _userService = userService;
        }

        /// <summary>
        /// 获取EmailAccount对象
        /// </summary>
        /// <returns>返回EmailAccount列表</returns>
        [HttpGet]
        [Api(Name = "获取邮箱列表", AllowAnonymous = false)]
        public PageResponse<EmailAccountDto> GetList([FromQuery] EmailAccountQueryDto query)
        {
            return _service.GetPageList(query);
        }

        ///// <summary>
        ///// 邮箱账号申请
        ///// </summary>
        //[Api(Name = "邮箱申请", AllowAnonymous = false)]
        //[HttpPost]
        //public void Apply()
        //{
        //    var user = ImApp.User;
        //    //目前直接创建，可以采取走审核流程的方式
        //    _service.Create(new EmailAccount { UserId = user.Id, IsActive = true, Account = $"{user.UserName}@im.com" });
        //    _userService.Update(s => s.LocalEmail == true, s => s.Id == user.Id);
        //}
    }
}
